{% extends "site_base.html" %}

{% load i18n %}
{% load uni_form %}
{% load ifsetting_tag %}

{% block head_title %}{% trans "Login" %}{% endblock %}

{% block body %}
    <h1>{% trans "Log In" %}</h1>

    {% if user.is_authenticated %}
        <p><span class="warning">{% trans "Note" %}</span>: {% blocktrans %}you are already logged in as {{ user }}.{% endblocktrans %}</p>
    {% else %}
        {% ifsetting ACCOUNT_OPEN_SIGNUP %}
        {% url acct_signup as signup_url %}
        <p>{% blocktrans %}Don't have an account? <a href="{{ signup_url }}">Sign up</a>!{% endblocktrans %}</p>
        {% endifsetting %}
    {% endif %}

    <form class="login uniForm" method="POST" action="">
        <fieldset class="inlineLabels">
            {{ form.as_p }}
            <div class="form_block">
                <input type="submit" value="{% trans "Log in &raquo;" %}" />
            </div>
            <div class="form_block">
                <a href="{% url acct_passwd_reset %}">{% trans "Forgot password?" %}</a>
            </div>
        </fieldset>
    </form>

    {% if not openid %}
        <br />
        <br />
        <p>{% trans "Or sign in with your OpenID" %}:</p>
        {# @@@ why isn't this just does as a form object ? #}
        <form class="login uniForm" action="/openid/register/" method="POST">
            <fieldset class="inlineLabels">
                {% if url_required %}
                    <p class="ctrlHolder error">
                        <p class="errorField">
                            <strong>This field is required.</strong>
                        </p>
                        <label for="id_username">OpenID Identifier: </label>
                        <input class="openid" type="text" name="openid_url" />
                    </p>
                {% else %}
                    <p class="ctrlHolder">
                        <label for="id_username">OpenID Identifier: </label>
                        <input class="openid" type="text" name="openid_url" />
                    </p>
                {% endif %}
                <div class="form_block">
                    <input type="submit" value="{% trans "Log in &raquo;" %}" />
                </div>
            </fieldset>
        </form>
    {% endif %}
    <br /><br />
    <p>{% blocktrans %}If you have any trouble logging in to your account, contact us at <a href="mailto:{{ contact_email }}">{{ contact_email }}</a>.{% endblocktrans %}</p>
{% endblock %}

{% block extra_body %}
<script>
    $("#id_username").focus();
</script>
{% endblock %}